<%@include file="_header.jspf" %>
<%@page import="com.spartancoder.accommodation.models.University" %>
<%@page import="com.spartancoder.accommodation.beans.UniversityBean" %>

<h2>Listare universitati</h2>

<table>
    <thead>
        <th>ID</th>
        <th>Nume</th>
        <th>Adresa</th>
        <th>Stare</th>
        <th>Operatii</th>
    </thead>
    <tbody>
<%
int count = 0;
for(UniversityBean ub : University.fetchAll()) {
%>
    <tr <%if(count++ % 2==0) {%>class="odd"<%} else {%>class="even"<%}%>>
        <td><%=ub.getUniversityId()%></td>
        <td>
            <a href="list-college.jsp?id=<%=ub.getUniversityId()%>">
                <%=ub.getName()%>
            </a>
        </td>
        <td><%=ub.getAddress()%></td>
        <td><% if(ub.isAvailable()) { %>Activa <%} else {%>Inactiva<%}%></td>
        <td>
            <a href="remove-university.jsp?id=<%=ub.getUniversityId()%>"
                onclick="return confirm('Esti sigur?')">sterge</a> - 
            <a href="switch-university.jsp?id=<%=ub.getUniversityId()%>">
                <% if(ub.isAvailable()) { %>
                    dezactiveaza
                <% } else { %>
                    activeaza
                <% } %>
            </a>
        </td>
    </tr>
<% } %>
    </tbody>
</table>

<%@include file="_footer.jspf" %>